﻿
namespace zyconfig
{
    public class DataBase
    {
        public static readonly string DbCon = GetConstr();
        public static readonly string DbType =DbConfig.DataBaseType.ToUpper();
        private static string GetConstr()
        {
            string str = string.Empty;
            if (DbConfig.DataBaseType.ToUpper() == "MSSQL")
            {
                str = "Provider=SQLOLEDB.1;Password=" + DbConfig.PassWord + ";Persist Security Info=True;User ID=" + DbConfig.UserName + ";Initial Catalog=" + DbConfig.DataBaseName + ";Data Source=" + DbConfig.ServerName;
            }
            if (DbConfig.DataBaseType.ToUpper() == "ORACLE")
            {
                str = "User ID=" + DbConfig.UserName + ";Password=" + DbConfig.PassWord + ";Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = " + DbConfig.ServerName+ ")(PORT = " + DbConfig.Port + "))) (CONNECT_DATA = (SERVICE_NAME = " + DbConfig.DataBaseName + ")))";
                //str = "Password=" + DbConfig.PassWord + ";User ID=" + DbConfig.UserName + ";Connection Lifetime=15;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + DbConfig.ServerName+ ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=GDLISNET)))";
                //str = "Provider=OraOLEDB.Oracle.1;Password=" + DbConfig.PassWord + ";Persist Security Info=True;User ID=" + DbConfig.UserName + ";Data Source=" + DbConfig.ServerName;
            }
            if (DbConfig.DataBaseType.ToUpper() == "ODBORA")
            {
                str = "Provider=OraOLEDB.Oracle.1;Password=" + DbConfig.PassWord + ";Persist Security Info=True;User ID=" + DbConfig.UserName + ";Data Source=" + DbConfig.DataBaseName;
            }
            if (DbConfig.DataBaseType.ToUpper() == "MYSQL")
            {
                str = "server = " + DbConfig.ServerName + "; user id = " + DbConfig.UserName + "; database = " + DbConfig.DataBaseName + "; password=" + DbConfig.PassWord + ";Allow User Variables=True;";
            }
            return str;
        }
    }
}
